package com.ruoyi.cbx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cbx.domain.FuelProduct;
import com.ruoyi.cbx.service.IFuelProductService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 燃料商品
Controller
 * 
 * @author Winston
 * @date 2025-08-14
 */
@RestController
@RequestMapping("/order/product")
public class FuelProductController extends BaseController
{
    @Autowired
    private IFuelProductService fuelProductService;

    /**
     * 查询燃料商品
列表
     */
    @PreAuthorize("@ss.hasPermi('order:product:list')")
    @GetMapping("/list")
    public TableDataInfo list(FuelProduct fuelProduct)
    {
        startPage();
        List<FuelProduct> list = fuelProductService.selectFuelProductList(fuelProduct);
        return getDataTable(list);
    }

    /**
     * 导出燃料商品
列表
     */
    @PreAuthorize("@ss.hasPermi('order:product:export')")
    @Log(title = "燃料商品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FuelProduct fuelProduct)
    {
        List<FuelProduct> list = fuelProductService.selectFuelProductList(fuelProduct);
        ExcelUtil<FuelProduct> util = new ExcelUtil<FuelProduct>(FuelProduct.class);
        util.exportExcel(response, list, "燃料商品数据");
    }

    /**
     * 获取燃料商品
详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:product:query')")
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") Long productId)
    {
        return success(fuelProductService.selectFuelProductByProductId(productId));
    }

    /**
     * 新增燃料商品

     */
    @PreAuthorize("@ss.hasPermi('order:product:add')")
    @Log(title = "燃料商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FuelProduct fuelProduct)
    {
        return toAjax(fuelProductService.insertFuelProduct(fuelProduct));
    }

    /**
     * 修改燃料商品

     */
    @PreAuthorize("@ss.hasPermi('order:product:edit')")
    @Log(title = "燃料商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FuelProduct fuelProduct)
    {
        return toAjax(fuelProductService.updateFuelProduct(fuelProduct));
    }

    /**
     * 删除燃料商品

     */
    @PreAuthorize("@ss.hasPermi('order:product:remove')")
    @Log(title = "燃料商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productIds}")
    public AjaxResult remove(@PathVariable Long[] productIds)
    {
        return toAjax(fuelProductService.deleteFuelProductByProductIds(productIds));
    }
}
